<!-- Modal -->
<div class="modal fade" id="paymentapiconfig" tabindex="-1" role="dialog" aria-labelledby="paymentapiconfig">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
           <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">支付参数配置</h4>
      </div>
        <div class="modal-body">
            <form class="setapiform" role="form"  method="post">  
            <input type="hidden" name="relid" />
            <div class="apiform"></div>
            </form>
        </div>
       <div class="modal-footer">
        <button type="button" class="btn btn-success" id="apisubmit">提交</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>
<script>
    $('#paymentapiconfig').on('show.bs.modal', function (event) {
        var button = $(event.relatedTarget);
        var rid=button.data("relid");
        $("input[name='relid']").val(rid);
        var url="<{echo Common::RewriteUrl("PayapiManage","public_ajax_paymentapiconfig");}>";
        $.post(url,{"rid":rid},function(data){
            $(".apiform").html(data.htmlform);
            for(var key in data.params){
                $("input[name='"+key+"']").val(data.params[key]);
            }
        },"json");
        $("#apisubmit").click(function(){
            var purl="<{echo Common::RewriteUrl("PayapiManage","public_ajax_setpaymentapiconfig");}>";
            $.ajax({
                type: "POST",
                url:purl,
                data:$('.setapiform').serialize(),
                dataType:"json",
                success: function(data) {
                    if(data.status==1){
                        
                    }else{
                        alert(data.msg);
                    }
                    $('#paymentapiconfig').modal('hide');
                }
            });
        });
    });
</script>